import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import rTime from 'dayjs/plugin/relativeTime'

dayjs.locale('zh-cn')
dayjs.extend(rTime)
export const relativeTime = yourTime => dayjs().to(dayjs(yourTime))
export const formatTime = time => dayjs(time).format('mm:ss')
export const formatDate = time => dayjs(time).format('YYYY年MM月DD日')
export const playCount = num => {
  if (num >= 100000000) {
    return parseInt(num / 100000000) + '亿+'
  }
  if (num >= 10000) {
    return parseInt(num / 10000) + '万+'
  }
  return num
}

export const comTotal = num => {
  if (num >= 99999) {
    return 10 + 'w+'
  }
  if (num >= 9999) {
    return 1 + 'w+'
  }
  if (num >= 999) {
    return 999 + '+'
  }
  return num
}

export const likedTotal = num => {
  if (num >= 99999) {
    return (num / 10000).toFixed(1) + 'w+'
  }
  if (num >= 9999) {
    return (num / 10000).toFixed(1) + 'w+'
  }
  return num
}
